package com.zhisheng.advice;

import com.zhisheng.pojo.MyResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
    全局异常统一处理器
    无论哪个controller service mapper出现异常 都会被这个处理器处理
*/
@RestControllerAdvice
public class MyAdviceController {
    @ExceptionHandler(Exception.class)
    public MyResponseResult<String> exceptionHandler(Exception e){
        //记录日志
        e.printStackTrace();
        return MyResponseResult.error("对不起，系统繁忙，请稍后再试");
    }
}
